<!--
 * @Author: Aaron Huang
 * @Date: 2022-10-21 15:56:25
 * @LastEditors: Aaron Huang
 * @LastEditTime: 2022-10-31 13:57:25
 * @Description: file content
 * @FilePath: \ias_ui\src\views\coi\CBEC\components\selectBuildingTypeDialog.vue
 * @Company: 沃尔玛
-->
<template>
  <el-dialog title="新增建品" :visible.sync="value" width="500px" :before-close="handleClose">
    <el-form ref="buildingTypeForm" :model="buildingTypeForm" :rules="rules" label-width="150px">
      <el-form-item label="请选择业务类型：" prop="goodsType">
        <el-radio-group v-model="buildingTypeForm.goodsType" disabled>
          <el-radio v-for="item in buildingType" :key="item.value" :label="item.value">{{ item.label }}</el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item label="请选择渠道：" prop="channelCodes">
        <el-checkbox-group v-model="buildingTypeForm.channelCodes" disabled>
          <el-checkbox v-for="item in constructionChannel" :key="item.value" :label="item.value" name="channelCodes">{{ item.label }}</el-checkbox>
        </el-checkbox-group>
      </el-form-item>
    </el-form>

    <span slot="footer" class="dialog-footer">
      <el-button size="mini" round @click="handleClose">取 消</el-button>
      <el-button type="primary" size="mini" round @click="submitForm">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { buildingType, constructionChannel } from '../js/dictionary'
export default {
  model: {
    prop: 'value',
    event: 'change'
  },
  props: {
    value: {
      type: Boolean,
      required: true
    },
    buildingTypeForm: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      buildingType,
      constructionChannel,
      rules: {
        goodsType: { required: true, message: '请选择业务类型', trigger: 'blur' },
        channelCodes: { required: true, message: '请选择业务类型', trigger: 'blur' }
      }
    }
  },
  methods: {
    handleClose() {
      this.$refs.buildingTypeForm.clearValidate()
      this.$emit('change', false)
    },
    submitForm() {
      this.$refs.buildingTypeForm.validate((_) => {
        if (_) this.$emit('submitBuildingTypeForm')
      })
    }
  }
}
</script>

<style lang="scss" scoped>
/deep/ .el-dialog__body {
  padding: 0 10px;
}
/deep/ .el-form-item {
  margin-bottom: 10px;
}
</style>
